function OS_Music(host,id)
{
	this.$super=OS_Resource;
	if (this.$super(host,id)===false) return;
	delete this.$super;
	
	var audio=new Audio();
	audio.loop=false;
	audio.preload=true;
	audio.audoplay=false;
	
	this.load=function(handler)
	{
		var instance=this;
		audio.addEventListener("canplay",function(){
			instance.loaded=true;
			handler(instance);
		});
		audio.src=this.resourceNode.getElementsByTagName("link")[0].textContent;
	}
	this.setLoop=function(isLoop){
	    audio.loop=isLoop;
	}
	
	this.play=function(){
		audio.play();
	}
	
	this.pause=function(){
		audio.pause();
	}
	
	this.stop=function()
	{
		audio.pause();
		audio.currentTime=0;
	}
	
	this.getVolume=function()
	{
		return Math.round(audio.volume*100);
	}
	
	this.setVolume=function(value)
	{
		if (value>100) value=100;
		if (value<0) value=0;
		audio.volume=value/100;
	}
	this.setHandler=function(type,handler){
		audio.addEventListener(type,handler);
	}
}

OS_Resource.Builder.put("music",OS_Music);
